<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.springframework.security.core.userdetails.User"%>

<%@page import="com.hexus.eve.utils.ServerStatus"%>

<link rel="stylesheet" type="text/css" href="css/header.css"/>

<table cellspacing="0" id="headerTable" class="fullWidth">
	<col width="300px"/><col align="center" width="50%"/><col/>
	<tr>
		<td id="logoCell" colspan="1"><span><a href="Home"><s:text name="logo"/></a></span></td>
		<td id="serverStatusCell"><span id="serverStatus"><s:text name="server.status"/>: 
			<%if (ServerStatus.isOnline()) {%>
				<span id="online"><s:text name="online"/></span><span id="onlinePlayers">
				<s:text name="players.online"/>: <%=ServerStatus.getOnlinePlayers()%></span>				
			<%} else if (ServerStatus.hasError()){%>
				<span title="<s:text name="undefined.description"/>" id="undefined"><s:text name="undefined"/><span style="position:relative;font-size: 8; top: -6px;">*</span></span>
			<%} else {%>
				<span id="offline"><s:text name="offline"/></span>
			<%}%></span>
			
		</td>
		<td id="languagesCell">
			<sec:authorize access="authenticated">
				<span>
					<s:text name="welcome">
						<s:param><sec:authentication property="principal.username"/></s:param>
					</s:text>
				</span>
			</sec:authorize>
			<s:url var="currenturl_en" includeParams="get" escapeAmp="false">
				<s:param name="request_locale">en_US</s:param>
			</s:url>
			<s:a href="%{currenturl_en}"><img border="0" alt="<s:text name="english.us"/>" src="img/en.png"/></s:a>
			
			<s:url var="currenturl_ru" includeParams="get" escapeAmp="false">
				<s:param name="request_locale">ru</s:param>
			</s:url>
			<s:a href="%{currenturl_ru}"><img border="0" alt="<s:text name="russian"/>" src="img/ru.png"/></s:a>

		</td>
	</tr>
	<tr>
		<!-- td id="searchCell">
				Search items:<form action="Search" ><sx:autocompleter showDownArrow="false" loadMinimumCount="3" preload="false" autoComplete="true" name="inputType" href="TypesAutocompleter.action" loadOnTextChange="true"/><input type="submit" value=">>"/></form>
		</td-->
		<td id="searchCell">
			<form action="Search" style="display:inline">
				<input type="hidden" name="page" value="1"/>
				<s:text name="quick.search"/>: <input id="name" name="name"/><input type="submit" value=">>"/>
			</form>
		</td>

		<td id="loginCell"  colspan="2">
			<sec:authorize ifAnyGranted="ROLE_USER">
				<span style="display:inline">
					<a href="Logout"><s:text name="logout"/></a>
					<a href="ChangePasswordForm"><s:text name="change.password"/></a>
				</span>
			</sec:authorize>
			<sec:authorize ifNotGranted="ROLE_USER">
				<form style="display:inline" action="j_spring_security_check" method="POST">
					<input type="hidden" name="change" value="true"/>
					<s:text name="username"/>: <input type="text" id="j_username" name="j_username"/> <s:text name="password"/>: <input type="password" id="j_password" name="j_password"/>
					<!-- input id="_spring_security_remember_me" name="_spring_security_remember_me" type="checkbox" value="true"/-->
					<!-- s:text name="remember"/-->
					<input type="submit" value="Login"/>
					<a href="RegisterForm"><s:text name="register"/></a>
				</form>
			</sec:authorize>
		</td>
	</tr>
</table>
